<template>
  <nut-row style="padding: 10px 10px">
    <nut-col :span="4">
      <nut-avatar icon="my"></nut-avatar>
    </nut-col>
    <nut-col :span="14">
      {{ tokenInfo.uid }}<br />
      <span style="font-size: 12px; color: #999">
        {{ tokenInfo.nickName }}</span
      >
    </nut-col>
  </nut-row>

  <div style="padding: 20px 20px">
    <nut-button style="width: 100%" type="primary" @click="logout()"
      >退出</nut-button
    >
  </div>

  <nut-tabbar
    @tab-switch="pages.tabSwitch"
    :bottom="true"
    v-model:visible="active"
  >
    <nut-tabbar-item
      tab-title="首页"
      icon="home"
      :to="pages.home"
    ></nut-tabbar-item>
    <nut-tabbar-item
      tab-title="设备"
      icon="category"
      :to="pages.devices"
    ></nut-tabbar-item>
    <nut-tabbar-item
      tab-title="我的"
      icon="my"
      :to="pages.my"
    ></nut-tabbar-item>
  </nut-tabbar>
</template>
<script lang="ts">
import Taro from "@tarojs/taro";
import pages from "../../services/pageConfig";

export default {
  setup() {
    const active = 2;
    const logout = () => {
      Taro.removeStorageSync("access_token");
      Taro.reLaunch({
        url: "/pages/login/login",
      });
    };

    const tokenInfo = Taro.getStorageSync("token_info");

    return { logout, pages, active, tokenInfo };
  },
};
</script>

<style lang="scss">
</style>